

####################################################
####          Replication Code for              ####
####     Bayesian versus maximum likelihood     ####
####      estimation of treatment effects       ####
####          in bivariate probit               ####  
####       instrumentalvariable models          ####    
####################################################
####                                            ####  
####                4/ 18/2017                  ####         
####     this file runs all the files for the   ####
####     Application                            ####
####################################################

### ATTENTION: STATA code has to be run first: file: Stata_probit_application.do

### set working directory to folder with files


sink("log_replication_Application.txt")


####################################################################
library(RColorBrewer)
library(superdiag)
library(pbivnorm)
library(rstan)
library(xtable)
library(devtools)
library(gdata)
library(haven)

### record computing environment
devtools::session_info()
sessionInfo()

### load functions to calculate LATE and ATE
source("HelperFunctions.R")

### load STATA ML results and calculate combined ML estimate
source("combinedMLE_calculation.R", echo = T)


#### Stan estimation of models
source("Application_Bayes_estimation.R", echo = TRUE)


#### Table and Figure creation, as well as calculations
source("Application_Table_Figures.R", echo = TRUE)


sink()
